<template>
	<view class="page">
		<view class="content">
			<view class="title">
				我的优势
			</view>
			
			<view class="tips md">
				一句话介绍自己，突出核心优势
			</view>
			
			<view class="area" >
				 <textarea maxlength="140" v-model="intro"/>
			</view>
			
			<view class="length md6Text">
				<text>{{intro.length}}</text>/140
			</view>
            <view style="margin-top: 60rpx;">
                <u-button type="primary" @click="nextStep()">确定</u-button>
            </view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			intro:'',
            
            is_resume: false,
		};
	},
    onLoad() {
        var resume = uni.getStorageSync('resume');
        if(resume) {
            this.is_resume = true;
            this.intro = resume.intro;
        }
    },
	methods: {
        nextStep() {
            if(!this.intro || !this.intro.trim()) {
                return this._toast('请输入我的优势');
            }
            if(this.is_resume) {
                this._ajax({
                    url: '/api/user/updateResume',
                    data: {
                        intro: this.intro,
                        step: 2
                    },
                    success: res => {
                        if(res.code == 1) {
                            uni.setStorageSync('resume', res.data);
                            this._toBack();
                        }else{
                            this._toast(res.msg);
                        }
                    }
                }, 1);
            }else {
                this._ajax({
                    url: '/api/user/intro',
                    data: {
                        intro: this.intro
                    },
                    success: res => {
                        if(res.code == 1) {
                            uni.setStorageSync('user', res.data);
                            if(res.data.step == 3) {
                                this._toView('login/step3');
                            }
                        }else{
                            this._toast(res.msg);
                        }
                    }
                }, 1);
            }
            
        }
	}
};
</script>

<style scoped lang="less">
	
	.page{
		width: 100%;
		box-sizing: border-box;
        background-color: #fff;
		.content{
			padding: 80upx 50upx;
			
			
			.title{
				font-size: 40upx;
			}
			
			.tips{
				padding-top: 30upx;
			}
			
			.area{
				margin-top: 60upx;
				padding-bottom: 40upx;
                
				textarea{
					width: 100%;
					height: 276upx;
					background: #F8F8F8;
					border-radius: 8upx;
					padding: 20upx;
					color: #333;
				}
			}
			
			.length{
				border-top: 2upx solid #e5e5e5;
				padding: 30upx 10upx;
			
				
				text-align: right;
				text{
					
					color: #00AAEF;
				}
			}
		}
	}
</style>
